import request from "./request.js";
const unit = {
	//token过期了重新请求获取token
	unit: async function(refreshToken, url, req) {
		let header = Object.assign({
			'content-type': 'application/json'
		}, {
			apiVersion: '1.0'
		}, {
			platform: 'WeChatMiniProgram'
		}, {
			platformVersion: '1.0'
		}, {
			'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.18(0x1800122f) NetType/4G Language/zh_CN miniProgram/huoniao refreshToken'
		});
		try {
			const res = await request.post({
				url: `include/ajax.php?service=member&action=updateAccessToken&refresh_token=${refreshToken}`,
				header: header
			});
			if (res) {
				let datas = res.data;
				req(datas);
			}
		} catch (e) {
			console.log('CatchClause', e);
			console.log('CatchClause', e);
			console.log(e);
		}
	}
}
export default unit;